﻿using LVYAN.Model;
using LVYAN.Model.AutoMation;
using LVYAN.Utils;
using System.Collections.Generic;
namespace LVYAN.Service.AIAPI
{
    /// <summary>
    /// 
    /// </summary>
    public class PriceManage : BaseAPI
    {
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static ReponseData<List<PriceModel>> GetPriceList(RobotModel Robot, string ConfigId, bool IsQun, string RoomName, string NickName, string Message)
        {
            var Cache = new AIConfig().GetConfigModel(nameof(PriceManage), nameof(GetPriceList)).Cache;

            var content = JsonService.ToString(new
            {
                ConfigId = ConfigId,
                IsQun = IsQun,
                RoomName = RoomName,
                NickName = NickName,
                Message = Message,
                RobotName = Robot.RobotName,
                RobotCode = Robot.RobotCode,
                MacAddress = WinInfo.GetMacAddress(),
                MacIP = WinInfo.GetIP(),
                MacName = WinInfo.GetHostName(),
            });
            var Result = CacheManage<ReponseData<List<PriceModel>>>.GetCache(content, () =>
            {
                new LoggerService().ResponseMsgDebug("查询费用", "发送消息", content);
                var result = new RequestService().PostJson($"{AIAPI}api/aichat/GetPriceList", content);
                if (string.IsNullOrWhiteSpace(result))
                {
                    return new ReponseData<List<PriceModel>> { ActionOK = false, };
                }
                var reponseData = JsonService.ToModel<ReponseData<List<PriceModel>>>(result);
                new LoggerService().ResponseMsgDebug("查询费用", "接受消息", reponseData);

                return reponseData;
            }, Cache);
            return Result;
        }
    }
}
